-
Notifications
You must be signed in to change notification settings - Fork 12.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rewrite relative import extensions with flag #59767
base: main
Are you sure you want to change the base?
Conversation
@typescript-bot pack this |
Hey @andrewbranch, I've packed this into an installable tgz. You can install it for testing by referencing it in your
and then running There is also a playground for this build and an npm module you can use via |
7159132
to
2b06e62
Compare
Looks like you're introducing a change to the public API surface area. If this includes breaking changes, please document them on our wiki's API Breaking Changes page. Also, please make sure @DanielRosenwasser and @RyanCavanaugh are aware of the changes, just as a heads up. |
bf25d52
to
a398ad1
Compare
ef2101a
to
0d95ce2
Compare
@typescript-bot pack this |
Hey @andrewbranch, I've packed this into an installable tgz. You can install it for testing by referencing it in your
and then running There is also a playground for this build and an npm module you can use via |
…le to not need rewriting
This PR adds
--rewriteRelativeImportExtensions
to support transforming module specifiers from e.g."./utils.ts"
to"./utils.js"
. A module specifier will be statically rewritten or shimmed during JS emit if it meets all of these criteria:.d.ts
,.d.mts
,.d.cts
,.d.*.ts
).ts
,.tsx
,.mts
, or.cts
Error checking
Errors are issued in an attempt to catch common mistakes:
"./foo.ts"
actually resolves to./foo.ts.ts
orfoo.ts/index.ts
"../other-project/src/index.ts"
belongs to another project where outputs go to a different outDir"#blah/foo.ts"
resolves tofoo.ts
where the.ts
matches through a wildcardSyntax support
import "./foo.ts"
import "./foo.js"
,require("./foo.js")
export * from "./foo.ts"
export * from "./foo.js"
import foo = require("./foo.ts")
import foo = require("./foo.js")
import(getPath())
import(__rewriteRelativeImportExtension(getPath()))
require("./foo.ts")
require(__rewriteRelativeImportExtension("./foo.js"))
import("foo")
import("foo")
require("foo")
require("foo")
require("./foo.ts")
require("./foo.ts")
(require)("./foo.ts")
(require)("./foo.ts")
Fixes #59597